import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: {
      username: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).username
    },
    changepwd:0,
    seconds: 0,
    usname: '', //
    ehoice: [], //单选题答案
    multiple: [], //多选题答案
    judge: [], //判断题答案
  },
  mutations: {
    login (state, user) {
      state.user = user
      window.localStorage.setItem('user', JSON.stringify(user))
    },
    changeOptions1(state, option){
      state.ehoice.push(option)
    },
    changeOptions2(state, option){
      state.multiple.push(option)
    },
    changeOptions3(state, option){
      state.judge.push(option)
    }
  }
})
